import { request } from './request'
import type { FAQ, PaginatedResponse } from '@/types'

// 获取FAQ列表
export const getFAQs = (params: {
  page: number
  page_size: number
  category?: string
  status?: number
}) => {
  return request<PaginatedResponse<FAQ>>({
    url: '/admin/faqs',
    method: 'get',
    params
  })
}

// 获取FAQ详情
export const getFAQ = (id: number) => {
  return request<FAQ>({
    url: `/admin/faqs/${id}`,
    method: 'get'
  })
}

// 创建FAQ
export const createFAQ = (data: Partial<FAQ>) => {
  return request<FAQ>({
    url: '/admin/faqs',
    method: 'post',
    data
  })
}

// 更新FAQ
export const updateFAQ = (id: number, data: Partial<FAQ>) => {
  return request<FAQ>({
    url: `/admin/faqs/${id}`,
    method: 'put',
    data
  })
}

// 删除FAQ
export const deleteFAQ = (id: number) => {
  return request({
    url: `/admin/faqs/${id}`,
    method: 'delete'
  })
}

